<?php
require_once 'LogView.php';
	class LogManager{
	
		public function validate($snum,$date,$term,$room){
		
			if(is_numeric($snum)&&($date!=""||$date!=null)&&($term!=""||$term!=null)&&($room!=""||$room!=null)){
					return true;
				}else{
					return false;
			}
		}
		
		public function insertLog($snum,$date,$term,$room,$date_out,$lname,$mname,$fname){	
			$conn=oci_connect("naiad","1234","localhost/XE");
			if(!$conn){
				$err[] = "Connection error!". var_dump(oci_error());
				echo '<script> alert("'.$err.'") </script>';
				die();
				oci_close($conn);
			}
			else{
				$stvio = oci_parse($conn,"insert into check_in(studentno,term,date_in,roomno,date_out,namefirst,namemiddle,namelast) values(:studentno,:term,:date_in,:roomno,:date_out,:namefirst,:namemiddle,:namelast)");
				oci_bind_by_name($stvio, ":studentno", $snum);
				oci_bind_by_name($stvio, ":term", $term);
				oci_bind_by_name($stvio, ":date_in", $date);
				oci_bind_by_name($stvio, ":roomno", $room);
				oci_bind_by_name($stvio, ":date_out", $date_out);
				oci_bind_by_name($stvio, ":namefirst", $fname);
				oci_bind_by_name($stvio, ":namemiddle", $mname);
				oci_bind_by_name($stvio, ":namelast", $lname);
				$exec1 = oci_execute($stvio);
				if($exec1==true){
					return 1;
				}
				oci_commit($conn);
				//oci_free_statement($stid);
				oci_close($conn);
			}	
		}		
	}//class
?>
